how to calculate the magnitude of a vector